﻿using System;
using fastCSharp;

namespace diantou.web
{
    /// <summary>
    /// 我的私信
    /// </summary>
    [fastCSharp.code.cSharp.webView(IsPage = false, IsPool = true)]
    partial class message : currentUserView<message>
    {
        /// <summary>
        /// 用户私信数量
        /// </summary>
        [fastCSharp.code.cSharp.webView.clientType(Name = "diantou.userMessage")]
        public struct userMessage
        {
            /// <summary>
            /// 对方最后一条私信
            /// </summary>
            public diantou.dataAccess.message Message;
            /// <summary>
            /// 对方最后一条私信标识
            /// </summary>
            [fastCSharp.code.cSharp.webView.outputAjax]
            public int Id
            {
                get { return Message.Id; }
            }
            /// <summary>
            /// 数量
            /// </summary>
            public int Count;
            /// <summary>
            /// 是否自己
            /// </summary>
            public bool IsSelf;
        }
        /// <summary>
        /// 
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private userMessage[] messages;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        private bool loadView(int page)
        {
            if (currentUserId != 0)
            {
                diantou.dataAccess.message.messageCount[] values = diantou.dataAccess.tcpCall.message.getCount(currentUser.Id, currentUser.IsChangeVisit, pageInfo.Size = fastCSharp.config.pub.Default.PageSize, pageInfo.Page = page, out pageInfo.Count);
                messages = values.getArray(value => new userMessage { Count = value.Count, Message = value.Message, IsSelf = value.Message.UserId == currentUserId });
                return true;
            }
            return false;
        }
    }
}
